package org.example;

public class Base64Util {
    public static String encode(byte[] bytes) {
        return java.util.Base64.getEncoder().encodeToString(bytes);
    }

    public static byte[] decode(String base64) {
        return java.util.Base64.getDecoder().decode(base64);
    }

    public static void main(String[] args) {
        String originalString = "HAK-yjglxt";
        byte[] bytes = originalString.getBytes();

        String base64 = encode(bytes);
        System.out.println("Base64: " + base64);

        byte[] decodedBytes = decode(base64);
        String decodedString = new String(decodedBytes);
        System.out.println("Decoded String: " + decodedString);

        /*
        * {
  "requestURL": "http://10.30.17.92:32219/HAK-BSN/api/bsn/findEmpBasicInfo",
  "appSystemId": "HAK-yjglxt",
  "secreKey": "sbEeZahbocfZr8Yk",
  "ContentType": "application/json",
  "xAuthorizationSign": "eyJhY2Nlc3NDbGllbnQiOiJtcy1iYXMtc3lzIiwicmFuZG9tU3RyIjoicXlrQ2xwRG9ndyIsInNlY3JldEtleSI6IktzYkhySHVnZUN2NHE3aCNod0plQmteZlRIckJkaHNVIiwic2lnbiI6ImI3ZDA2YThlZGIwNzIyYjQ1MTk2ZGJkOGQzNjIxOGJmYTUyYmMxY2IzOWZmZjQzZDVlNDc3NTc2NDYzNWViMTYiLCJzeXN0ZW1JZCI6InNpbSIsInRpbWVTdGFtcCI6MTY0ODE3Njk3NjYxNywidXNlcklkIjoxfQ=="
}
        * */

        String str ="{\n" +
                "  \"requestURL\": \"http://10.30.17.92:32219/HAK-BSN/api/bsn/findEmpBasicInfo\",\n" +
                "  \"appSystemId\": \"HAK-yjglxt\",\n" +
                "  \"secreKey\": \"sbEeZahbocfZr8Yk\",\n" +
                "  \"ContentType\": \"application/json\",\n" +
                "  \"xAuthorizationSign\": \"eyJhY2Nlc3NDbGllbnQiOiJtcy1iYXMtc3lzIiwicmFuZG9tU3RyIjoicXlrQ2xwRG9ndyIsInNlY3JldEtleSI6IktzYkhySHVnZUN2NHE3aCNod0plQmteZlRIckJkaHNVIiwic2lnbiI6ImI3ZDA2YThlZGIwNzIyYjQ1MTk2ZGJkOGQzNjIxOGJmYTUyYmMxY2IzOWZmZjQzZDVlNDc3NTc2NDYzNWViMTYiLCJzeXN0ZW1JZCI6InNpbSIsInRpbWVTdGFtcCI6MTY0ODE3Njk3NjYxNywidXNlcklkIjoxfQ==\"\n" +
                "}";

        String requestUrlBase64 = Base64Util.encode("http://10.30.17.92:32219/HAK-BSN/api/bsn/findEmpBasicInfo".getBytes());

        String appSystemIdBase64 = Base64Util.encode("HAK-yjglxt".getBytes());
        String secreKeyBase64 = Base64Util.encode("sbEeZahbocfZr8Yk".getBytes());
        String contentTypeBase64 = Base64Util.encode("application/json".getBytes());
        String xAuthorizationSignBase64 = Base64Util.encode("eyJhY2Nlc3NDbGllbnQiOiJtcy1iYXMtc3lzIiwicmFuZG9tU3RyIjoicXlrQ2xwRG9ndyIsInNlY3JldEtleSI6IktzYkhySHVnZUN2NHE3aCNod0plQmteZlRIckJkaHNVIiwic2lnbiI6ImI3ZDA2YThlZGIwNzIyYjQ1MTk2ZGJkOGQzNjIxOGJmYTUyYmMxY2IzOWZmZjQzZDVlNDc3NTc2NDYzNWViMTYiLCJzeXN0ZW1JZCI6InNpbSIsInRpbWVTdGFtcCI6MTY0ODE3Njk3NjYxNywidXNlcklkIjoxfQ==".getBytes());

        String json = "{\n" +
                "  \"requestURL\": \"" + requestUrlBase64 + "\",\n" +
                "  \"appSystemId\": \"" + appSystemIdBase64 + "\",\n" +
                "  \"secreKey\": \"" + secreKeyBase64 + "\",\n" +
                "  \"ContentType\": \"" + contentTypeBase64 + "\",\n" +
                "  \"xAuthorizationSign\": \"" + xAuthorizationSignBase64 + "\"\n" +
                "}";

        System.out.println(json);

    }
}
